package cz.vargarob.spring.aop.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cz.vargarob.spring.aop.entity.Person;
import cz.vargarob.spring.aop.repo.PersonRepository;
import cz.vargarob.spring.aop.util.MyAnnotation;

@Service
public class PrinterServiceImpl implements PrinterService {

	private PersonRepository personRepo = null;
	
	@Autowired
	public PrinterServiceImpl(PersonRepository personRepo) {
		super();
		this.personRepo = personRepo;
	}
	
	

	public void printAll() {
		print(personRepo.getAll());
		printDummy();
	}

	@MyAnnotation(name="someParam")
	public void printAllByLastName(String lastName) {
		print(personRepo.getAllByLastName(lastName));
	}

	public void printAllByFirstName(String firstName) {
		
	}
	
	public void printDummy(){
		System.out.println("Dummy");
	}
	
	private void print(List<Person> listOfPeople){
		for (Person p : listOfPeople){
			System.out.println(p);
		}
	}

}
